export function useFilterTable<T>(tableData: T[], keys: (keyof T)[]) {
  const [filterString, setFilterString] = useState('');

  const filteredTableDate = useMemo(() => {
    if (!filterString) {
      return tableData;
    }
    return tableData.filter((item) => {
      const filterStringList = filterString.split(/\s+/);
      return keys.some((key) => {
        return filterStringList.some((filterStringItem) => {
          return String(item[key]).includes(filterStringItem);
        });
      });
    });
  }, [filterString, tableData, keys]);

  return {
    filterString,
    setFilterString,
    filteredTableDate,
  };
}
